package proxypattern.entity;

import proxypattern.base.IPersonBean;

/**
 * 个人信息实体类
 *
 * @author yaojianfeng
 */
public class PersonBean implements IPersonBean {
    private String name;
    private String gender;
    private String interests;
    private int rating;
    private int ratingCount = 0;

    /**
     * 获取姓名
     *
     * @return 姓名
     */
    @Override
    public String getName() {
        return name;
    }

    /**
     * 获取性别
     *
     * @return 性别
     */
    @Override
    public String getGender() {
        return gender;
    }

    /**
     * 获取兴趣
     *
     * @return 兴趣
     */
    @Override
    public String getInterests() {
        return interests;
    }

    /**
     * 获取配对评分 1~10
     * 除了setHotOrNotRating() 它计算Rating的平均值
     *
     * @return 评分
     */
    @Override
    public int getHotOrNotRating() {
        if (ratingCount == 0) {
            return 0;
        }
        return rating / ratingCount;
    }

    /**
     * 设置姓名
     *
     * @param name
     */
    @Override
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 设置性别
     *
     * @param gender
     */
    @Override
    public void setGender(String gender) {
        this.gender = gender;
    }

    /**
     * 设置兴趣爱好
     *
     * @param interests
     */
    @Override
    public void setInterests(String interests) {
        this.interests = interests;
    }

    /**
     * 设置配对评分
     * 增加计数值 并将参数加到rating实例变量中
     * @param rating
     */
    @Override
    public void setHotOrNotRating(int rating) {
        this.rating += rating;
        ratingCount++;
    }



}
